//Erstellt von Moritz Liepe
package main;

import java.util.UUID;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Rectangle;

public class LabelControl extends Figure implements IModuleControl{
	
	private int x, y, width, height;
	private String type, address, initialText;
	private boolean connectable;
	private final XYLayout layout = new XYLayout();
	private UUID id;
	
	private Label label;
	
	public LabelControl(){
		id = UUID.randomUUID();
	}

	public UUID getID()
	{
		return this.id;
	}
	
	public void setID(String ID){
		this.id = UUID.fromString(ID);
	}
	
	public String getType() {
		return type;
	}

	
	public String getAddress() {
		return address;
	}

	
	public boolean isConnectable() {
		return connectable;
	}

	
	public int getX() {
		return x;
	}

	
	public void setX(int x) {
		this.x = x;
	}

	
	public int getY() {
		return y;
	}

	
	public void setY(int y) {
		this.y = y;
	}

	
	public int getWidth() {
		return width;
	}

	
	public void setWidth(int width) {
		this.width = width;
	}

	
	public int getHeight() 
	{
		return height;
	}

	
	public void setHeight(int height) 
	{
		this.height = height;
	}

	
	public void setType(String type) 
	{
		this.type = type;
	}

	
	public void setAddress(String address) 
	{
		this.address = address;
	}

	
	public void setConnectable(boolean connectable) 
	{
		this.connectable = connectable;
	}

	public String getInitialText() {
		return initialText;
	}

	public void setInitialText(String initialText) {
		this.initialText = initialText;
	}
	
	
	public void paint() 
	{
		if(this.label == null)
		{
			this.setLayoutManager(layout);	
			this.setOpaque(true);
			this.setBackgroundColor(ColorConstants.white);
			this.setBorder(new LineBorder(ColorConstants.black));
			
			this.label = new Label("");
			this.add(label, new Rectangle(0, 0, width, height));
		}
	}

	@Override
	public String getValue() 
	{
		if(this.label == null)
		{
			return new String();
		}
		return this.label.getText();
	}

	@Override
	public void setValue(String value) 
	{
		if(this.label != null)
		{
			this.label.setText(value);
		}
	}
	
}
